//package quartztest;
//
//import Bean.MailBean;
//import org.quartz.JobExecutionContext;
//import org.quartz.JobExecutionException;
//import org.springframework.scheduling.quartz.QuartzJobBean;
//import org.springframework.stereotype.Service;
//import com.datatrees.notify.mail.MonitorMailService;
//import javax.annotation.Resource;
//import java.io.File;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by eleven on 15/11/20.
// */
//@Service(value = "testquartz")
//public class testquartz extends QuartzJobBean {
//
//    @Resource(name = "monitorMailService")
//    private MonitorMailService monitorMailService;
//
//    public void setMonitorMailService(MonitorMailService monitorMailService) {
//        this.monitorMailService = monitorMailService;
//    }
//
//    /**mail 配置**/
//    public static final String MAIL_SUBJECT1 = "个人测试文件";
//    public static final String MAIL_TEMPLATE_PATH = "/Users/eleven/workplace/data-center/artifacts/datacenter_explored/WEB-INF/classes/template";
//
//
//    public void dosometing(){
//        try{
//            System.out.println("quartz is done!");
//
//            String mail[]={"sunzhenchao@treefinance.com.cn"};
//            List<MailBean> listmailBean= new ArrayList();
//            Map<String, Object> mailData = new HashMap<String, Object>();
//
////            MailBean testMB = new MailBean();
////            testMB = test(0);
////            listmailBean.add(testMB);
////            testMB = test(1);
////            listmailBean.add(testMB);
////            testMB = test(2);
////            listmailBean.add(testMB);
////            mailData.put("data",listmailBean);
////            String ss=BuildMailTemplate("main.vm", mailData);
//            /**send mail**/
//            try {
////                dumonitorMailService.sendSimpleMail(mail, MAIL_SUBJECT1, ss);
//            } catch (Exception e) {
//                System.out.println("send mail failed:" + e.toString());
////                logger.error("send mail failed:" + e.toString());
//            }
//            System.out.println("\n没有问题");
//
//
//        }catch(Exception ex){
//            System.out.println("question in testquartz");
//            ex.printStackTrace();
//        }
//    }
//
//    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
//        try{
//            System.out.println("quartz is done!");
//
//            System.out.println("quartz is done!,file mail");
//            String mail[]={"sunzhenchao@treefinance.com.cn"};
////            List<MailBean> listmailBean= new ArrayList();
////            Map<String, Object> mailData = new HashMap<String, Object>();
//
////            MailBean testMB = new MailBean();
////            testMB = test(0);
////            listmailBean.add(testMB);
////            testMB = test(1);
////            listmailBean.add(testMB);
////            testMB = test(2);
////            listmailBean.add(testMB);
////            mailData.put("data",listmailBean);
////            String ss=BuildMailTemplate("main.vm", mailData);
//            String ss= "onetest";
//            File file = new File("test.txt");
//            File[] files=new File[]{file};
//            /**send mail**/
//            try {
//                monitorMailService.sendHtmlOfAttachedMail(mail, MAIL_SUBJECT1, ss, files);
////                monitorMailService.sendSimpleMail(mail, MAIL_SUBJECT1, ss);
////                monitorMailService.
//            } catch (Exception e) {
//                System.out.println("send mail failed:" + e.toString());
////                logger.error("send mail failed:" + e.toString());
//            }
//            System.out.println("\n没有问题");
//
//
//        }catch(Exception ex){
//            System.out.println("question in testquartz");
//            ex.printStackTrace();
//        }
//
//    }
//    /**
//     * 构造带有vm模板的邮件正文
//     *
//     * @param template
//     * @param mailData
//     * @return
//     */
////    private String BuildMailTemplate(String template, Map<String, Object> mailData) {
////        Properties properties = new Properties();
////        properties.setProperty(Velocity.RESOURCE_LOADER, "file");
////        properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, MAIL_TEMPLATE_PATH);
////        VelocityEngine velocityEngine = new VelocityEngine(properties);
////        return VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "mail.vm", "UTF-8", mailData);
////    }
////
////    private MailBean test(int i){
////        BigDecimal testB = new BigDecimal("1");
////        MailBean test = new MailBean();
////        if (i==0) {
////
////            test.setCount(testB);
////            test.setRuledesc("第一条测试");
////            test.setRulecode("T1");
////            test.setRatio(testB);
////            test.setFazhi(testB);
////        }
////        if (i==1){
//////            MailBean test = new MailBean();
////            test.setCount(testB);
////            test.setRuledesc("第二条测试");
////            test.setRulecode("T2");
////            test.setRatio(testB);
////            test.setFazhi(testB);
////        }
////        if (i==2){
//////            MailBean test = new MailBean();
////            test.setCount(testB);
////            test.setRuledesc("第三条测试");
////            test.setRulecode("T3");
////            test.setRatio(testB);
////            test.setFazhi(testB);
////        }
////        return  test;
////    }
//}
